package com.demo.cloud.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    RestTemplate restTemplate;
    @RequestMapping("/send")
    public List send(String msg) {
        System.out.println("1 client:"+msg);
        HashMap<String,String> result = new HashMap<>();
        result.put("msg",msg);
        result.put("guid", UUID.randomUUID().toString());
        System.out.println(result);
        return new ArrayList(){{add(result);add("dddd");}};
    }
    @RequestMapping("/call")
    public Object call(String msg){
        String result = restTemplate.getForObject("http://service-test/service/test/send?msg="+msg,String.class);
        return "result"+result;
    }

}
